﻿using System; 
using System.Windows.Forms;

namespace LiAnProxy
{
    public partial class AddHttpProxy : Form
    {
        public ReturnHandle ReturnDelegate;
        public AddHttpProxy()
        {
            InitializeComponent();
        }

        private void ConfirmBtn_Click(object sender, EventArgs e)
        {

            ProxyModel socketModel = null;
            try
            {
                int port;
               
                if (!int.TryParse(txtPort.Text, out port))
                {
                    MessageBox.Show(@"代理端口不是合法的数字", @"错误");
                    return;
                }
                 
                socketModel = new ProxyModel
                {
                    ProxyType=ProxyType.Http, 
                    ProxyPort = port,
                    ProxyIp = ProxyIpTxt.Text.Trim(),
                    TargetTimeOut = Convert.ToInt32(TargetTimeOutText.Text),
                    ProxyMax = Convert.ToInt32(ProxyMaxText.Text)
                     
                };
            }
            catch (Exception ex)
            {
                MessageBox.Show(@"错误", ex.Message);
            }
            if (ReturnDelegate != null)
                ReturnDelegate(socketModel);
            Close();
        }
    }
}
